//package org.chs.ts.batch.job;
//
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.BeansException;
//import org.springframework.context.ApplicationContext;
//import org.springframework.context.ApplicationContextAware;
//
///**
// * @Compay 盛唐天行
// * @Author: wuwei
// * @Censor By wuwei
// * @Sence 2023/12/19 11:15
// * @Modify 2023/12/19 11:15
// * @Description 定时测试
// */
////@EnableScheduling
////@Component
//@Slf4j
//public class BatchTestAsyncScheduled implements ApplicationContextAware {
////    @Resource
////    private IPmcsClearBasicTaskStepExecService pmcsClearBasicTaskStepExecService;
//
////    @Resource
////    private IPmcsClearBasicTaskExecService pmcsClearBasicTaskExecService;
////    @Resource
////    private batchExecController batchExecController;
////
////    @Resource
////    private TempTokenUtil tempTokenUtil;
//
//
//    // 每小时 00分05秒 30分05秒 执行
//     //@Scheduled(cron = "0/2 * * * * ?")
//    public void process() {
////        String taskExecId = "20250320000001PMCS001";
////        String snatchingMode ="redis";
////        UserTokenContext.setToken(tempTokenUtil.getTempToken());
////        log.info("------------------------BatchTestAsyncScheduled 测试 并发调用 "+taskExecId+"同一个 任务 ------------------------");
////        BatchExecResp batchExecResp = batchExecController.processByTaskExecId(taskExecId, snatchingMode);
////        log.info("------------------------BatchTestAsyncScheduled 测试 并发调用 "+taskExecId+"结果 "+batchExecResp.getRtnCode()+"------------------------");
////        UserTokenContext.remove();
//
//        //  1、batchController.processByTaskExecId  -> TaskExecFactory.doTaskExecByTaskExecId
////        String taskExecId = "20250314000001PMCS001";
////        String snatchingMode = "redis";
////        UserTokenContext.setToken(tempTokenUtil.getTempToken());
////        log.info("------------------------BatchTestAsyncScheduled 测试 并发调用 " + taskExecId + "同一个 任务 ------------------------");
////        BatchExecResp batchExecResp = batchExecController.processByTaskExecId(taskExecId, snatchingMode);
////        log.info("------------------------BatchTestAsyncScheduled 测试 并发调用 " + taskExecId + "结果 " + batchExecResp.getRtnCode() + "------------------------");
////        UserTokenContext.remove();
//
//        // 2、batchController.process -> TaskExecFactory.doTaskExec
//
////        String taskExecId = "20250314000001PMCS001";
////        String snatchingMode = "redis";
////        String taskGroup = "000001";
////        String execDate = "20250314";
////        UserTokenContext.setToken(tempTokenUtil.getTempToken());
////        log.info("------------------------BatchTestAsyncScheduled 测试 并发调用 " + taskExecId + "同一个 任务 ------------------------");
////        List<PmcsClearBasicTaskExec> list = pmcsClearBasicTaskExecService.list(new LambdaQueryWrapper<PmcsClearBasicTaskExec>().eq(PmcsClearBasicTaskExec::getExecDate, execDate).eq(PmcsClearBasicTaskExec::getTaskGroup, taskGroup));
////        for (PmcsClearBasicTaskExec item : list) {
////            item.setExecStatus("0");
////            pmcsClearBasicTaskExecService.updateByObject(item);
////        }
////        batchExecController.createTaskWaittingList(taskGroup, execDate, snatchingMode);
////        batchExecController.startTaskRunningStatus(taskGroup, execDate, snatchingMode);
////        Result<BatchExecResp> task = batchExecController.getTask(taskGroup, execDate, snatchingMode);
////        BatchExecResp batchExecResp =null;
////        if (task.getResult().getTaskExecId()!=null) {
////            batchExecResp = batchExecController.process(task.getResult().getTaskExecId(), snatchingMode);
////
////        }
////        batchExecController.stopTaskRunningStatus(taskGroup,execDate,snatchingMode);
////        log.info("------------------------BatchTestAsyncScheduled 测试 并发调用 " + taskExecId + "结果 " + (batchExecResp==null?"未执行 process":batchExecResp.getRtnCode()) + "------------------------");
////        UserTokenContext.remove();
//
//        // batchController.getTask -> TaskExecFactory.getPmcsClearBasicTaskExecByAvailableTaskExec
//        //-> TaskExecFactory.taskExecRunningOverTimeGC
////        String taskGroup = "000001";
////        String execDate = "20250325";
////        String snatchingMode = "redis";
////        UserTokenContext.setToken(tempTokenUtil.getTempToken());
////        log.info("------------------------BatchTestAsyncScheduled 测试 并发调用  getTask 同一个 任务 ------------------------");
////        List<PmcsClearBasicTaskExec> list = pmcsClearBasicTaskExecService.list(new LambdaQueryWrapper<PmcsClearBasicTaskExec>().eq(PmcsClearBasicTaskExec::getExecDate, execDate).eq(PmcsClearBasicTaskExec::getTaskGroup, taskGroup));
////        for (PmcsClearBasicTaskExec item : list) {
////            item.setExecStatus("0");
////            pmcsClearBasicTaskExecService.updateByObject(item);
////        }
////        batchExecController.createTaskWaittingList(taskGroup, execDate, snatchingMode);
////        batchExecController.startTaskRunningStatus(taskGroup, execDate, snatchingMode);
////        Result<BatchExecResp> task = batchExecController.getTask(taskGroup, execDate, snatchingMode);
////        batchExecController.stopTaskRunningStatus(taskGroup, execDate, snatchingMode);
////        log.info("------------------------BatchTestAsyncScheduled 测试 并发调用 getTask 结果 " + task.getResult() + "------------------------");
////        UserTokenContext.remove();
//
//    }
//
//
//    private static ApplicationContext context;
//
//    @Override
//    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
//        context = applicationContext;
//    }
//}
